﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Website.Models.ModelMetadata
{
    public class ProductListViewModel
    {
        public IEnumerable<ProductViewModel> Products { get; set; }
        public PagingInfo PagingInfo { get; set; }
        public int Category { get; set; }
        public string Search { get; set; }
    }

    public class ProductViewModel
    {
        public string ProductCode { get; set; }
        [DisplayFormat(DataFormatString = "#,##0.#0")]
        public decimal Price { get; set; }
        public string SmallMainImage { get; set; }
    }

    public class PagingInfo
    {
        public int TotalItems { get; set; }
        public int ItemPerPage { get; set; }
        public int CurrentPage { get; set; }

        public int TotalPage
        {
            get { return (int) Math.Ceiling((decimal) TotalItems/ItemPerPage); }
        }
    }

    public class ProductMetadata
    {
        public Category Category { get; set; }

        [UIHint("CategoryID")]
        [Required]
        public int CategoryID { get; set; }

        public string Desc { get; set; }

        [UIHint("ImageUpload")]
        [Required]
        public string MainImage { get; set; }

        [Required]
        [Remote("CheckProductCode","Product",AdditionalFields = "ProductID",ErrorMessage = "ProductCode existed")]
        public string ProductCode { get; set; }

        [UIHint("ProductSizes")]
        public IEnumerable<ProductSize> ProductSizes { get; set; }

        [UIHint("ImageUpload")]
        [Required]
        public string SmallImage { get; set; }

        [UIHint("ImageUpload")]
        public string SubImage1 { get; set; }

        [UIHint("ImageUpload")]
        public string SubImage2 { get; set; }

        [UIHint("ImageUpload")]
        public string SubImage3 { get; set; }

        [UIHint("PriceLevelID")]
        public int PriceLevelID { get; set; }

        public PriceLevel PriceLevel { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,##0}")]
        public decimal? Price { get; set; }
    }
}